home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / editor / yg407w95.zip / YGREP.H < prev    next >
C/C++ Source or Header  |  1996-05-08  |  5KB  |  193 lines

  1. /*
  2. //    $Id: ygrep.h 1.10 1996/04/08 01:41:07 Y.Roumazeilles Exp $
  3. //
  4. //    (C) 1992-93-94-95-96 Yves Roumazeilles
  5. //
  6. //      Version 5.0
  7. */
  8.  
  9. #ifndef    __YGREP_H__
  10. #define    __YGREP_H__    
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14.  
  15.  
  16. #ifdef    WINVER
  17. #define    YGCALL    FAR PASCAL
  18. #else
  19. #define    YGCALL    
  20. #endif
  21.  
  22. WORD    YGCALL    YGrepVersion( void );
  23. BOOL    YGCALL    YGrepIsDebug( void );
  24.  
  25.  
  26. /* YGrep Search Engine Error Codes */
  27. #define AGERR_UNKNOWN_TYPE        -1
  28. #define AGERR_NO_ERROR            0
  29. #define AGERR_STATE            1
  30. #define AGERR_ALLOC_MEM            2
  31. #define AGERR_TOO_SHORT            3
  32. #define AGERR_TOO_LONG            4
  33. #define AGERR_NO_PREVIOUS        5
  34. #define AGERR_NO_PATTERN        6
  35.  
  36. #define RGERR_MUNGED_AUTO        20
  37. #define RGERR_MISS_BRACKET        25
  38. #define RGERR_EMPTY_ENCL        26
  39. #define RGERR_ILLEGAL_ENCL        27
  40. #define RGERR_TOO_MANY_PAR        28
  41. #define RGERR_NULL_IN_PAR        29
  42. #define RGERR_UNMATCHED            30
  43. #define RGERR_NULL_IN_CRO        31
  44. #define RGERR_CYCLICAL_REF        32
  45. #define RGERR_UNDETERM_REF        33
  46. #define RGERR_UNMATCHED_PAR        34
  47.  
  48. #define    MATCH        0
  49. #define    MISMATCH    1
  50. #define    EXACTMATCH    2
  51. #define    MAXSYM        256    /* Size of the alphabet (in chars) */
  52. #define    WORD_SIZE    512    /* (in bits) */
  53. #define MAXTAG        10
  54.  
  55. #include    <bitlist.h>
  56.  
  57. typedef struct tagAGrepInfo {
  58.     int    iErrorCode;
  59.     char    cPat[WORD_SIZE];
  60.     LPSTR    TagStart[MAXTAG];
  61.     LPSTR    TagEnd[MAXTAG];
  62.     int    bMatchCase;
  63.     BLIST    uMask;        /* internal structures */
  64.     BLIST    uOvMask;
  65.     BLIST    uLimit;
  66.     BLIST    blState;    /* temporary AGrep() structures */
  67.     BLIST    blOverflow;
  68.     BLIST    blTemp;
  69.     BLIST    uTable[MAXSYM];    /* characteristic vector table */
  70.     int    iBitsPerState;
  71.     int    iWordSize;    /* actual word size of BLIST's */
  72.     int    iType;        /* MATCH or MISMATCH */
  73.     char    cUPat[WORD_SIZE];
  74. } AGREPINFO;
  75. #ifdef    WINVER
  76. typedef    AGREPINFO*    PAGREPINFO;
  77. typedef    AGREPINFO FAR*    LPAGREPINFO;
  78. #else
  79. typedef    AGREPINFO*    PAGREPINFO;
  80. typedef    AGREPINFO*    LPAGREPINFO;
  81. #endif
  82.  
  83.  
  84. int    YGCALL    CompileAGrep( LPCSTR GrepString, int k, BOOL bMatchCase, LPAGREPINFO pGI );
  85. int    YGCALL    AGrep( LPCSTR StringToSearch, LPAGREPINFO pGI );
  86. int    YGCALL    AGrepInit( LPAGREPINFO pGI );
  87. int    YGCALL    AGrepEmpty( LPAGREPINFO pGI );
  88. int    YGCALL    AGrepSubsBuild( LPSTR lpszPattern, LPSTR lpszDest, int iSize, LPAGREPINFO pGI );
  89. int    YGCALL    AGrepSubstitute( LPSTR SearchedString, LPSTR lpszPattern, LPSTR lpszDest, int iSize, LPAGREPINFO pGI );
  90. int    YGCALL    SCompileAGrep( LPCSTR GrepString, int k, BOOL bMatchCase );
  91. int    YGCALL    SAGrep( LPCSTR StringToSearch );
  92. int    YGCALL    SAGrepInit( void );
  93. int    YGCALL    SAGrepEmpty( void );
  94. int    YGCALL    SAGrepSubsBuild( LPSTR lpszPattern, LPSTR lpszDest, int iSize );
  95. int    YGCALL    SAGrepSubstitute( LPSTR SearchedString, LPSTR lpszPattern, LPSTR lpszDest, int iSize );
  96.  
  97.  
  98.  
  99. #define    MAXDFA    2*WORD_SIZE
  100.  
  101. #define CHRBIT    8
  102. #define BITBLK    MAXSYM/CHRBIT
  103.  
  104. typedef struct tagRGrepInfo {
  105.     int    iErrorCode;
  106.     char    cPat[WORD_SIZE];
  107.     LPSTR    TagStart[MAXTAG];
  108.     LPSTR    TagEnd[MAXTAG];
  109.     int    bMatchCase;
  110.     int    iCircf;        /* internal structures */
  111.     char    cDFA[MAXDFA];
  112. } RGREPINFO;
  113. #ifdef    WINVER
  114. typedef    RGREPINFO*    PRGREPINFO;
  115. typedef    RGREPINFO FAR*    LPRGREPINFO;
  116. #else
  117. typedef    RGREPINFO*    PRGREPINFO;
  118. typedef    RGREPINFO*    LPRGREPINFO;
  119. #endif
  120.  
  121. int    YGCALL    CompileRGrep( LPCSTR GrepString, BOOL bMatchCase, LPRGREPINFO pGI );
  122. int    YGCALL    RGrep( LPCSTR StringToSearch, LPRGREPINFO pGI );
  123. int    YGCALL    RGrepSubsBuild( LPSTR lpszPattern, LPSTR lpszDest, int iSize, LPRGREPINFO pGI );
  124. int    YGCALL    RGrepSubstitute( LPSTR SearchedString, LPSTR lpszPattern, LPSTR lpszDest, int iSize, LPRGREPINFO pGI );
  125. void    YGCALL    InitWordCharTable( void );
  126. void    YGCALL    AddWordChar( LPSTR s );
  127. void    YGCALL    RemoveWordChar( LPSTR s );
  128. int    YGCALL    SCompileRGrep( LPCSTR GrepString, BOOL bMatchCase );
  129. int    YGCALL    SRGrep( LPCSTR StringToSearch );
  130. int    YGCALL    SRGrepSubsBuild( LPSTR lpszPattern, LPSTR lpszDest, int iSize );
  131. int    YGCALL    SRGrepSubstitute( LPSTR SearchedString, LPSTR lpszPattern, LPSTR lpszDest, int iSize );
  132.  
  133.  
  134.  
  135.  
  136.  
  137. typedef struct tagOperInfo {
  138.     int    iErrorCode;
  139.     int    iOperator;    /* One of OP_* values */
  140. } OPERINFO;
  141. #ifdef    WINVER
  142. typedef    OPERINFO*    POPERINFO;
  143. typedef    OPERINFO FAR*    LPOPERINFO;
  144. #else
  145. typedef    OPERINFO*    POPERINFO;
  146. typedef    OPERINFO*    LPOPERINFO;
  147. #endif
  148.  
  149. #define    OP_NOP    0
  150. #define    OP_NOT    1
  151. #define    OP_AND    2
  152. #define    OP_OR    3
  153. #define    OP_NAND    4
  154. #define    OP_NOR    5
  155. #define    OP_ADD    6
  156. #define    OP_SUB    7
  157.  
  158.  
  159.  
  160.  
  161. typedef    struct tagYGrepInfo {
  162.     union {
  163.         OPERINFO    opI;
  164.         AGREPINFO    aGI;
  165.         RGREPINFO    rGI;
  166.     } info;
  167. #ifdef    WINVER
  168.     struct tagYGrepInfo FAR*    pInfo;
  169. #else
  170.     struct tagYGrepInfo *       pInfo;
  171. #endif
  172.     int    iTypeOfInfo;    /* One of IT_* values */
  173. } YGREPINFO;
  174. #ifdef    WINVER
  175. typedef    YGREPINFO*    PYGREPINFO;
  176. typedef    YGREPINFO FAR*    LPYGREPINFO;
  177. #else
  178. typedef    YGREPINFO*    PYGREPINFO;
  179. typedef    YGREPINFO*    LPYGREPINFO;
  180. #endif
  181.  
  182. #define    IT_NONE    -1
  183. #define    IT_OP    0
  184. #define    IT_AG    1
  185. #define    IT_RG    2
  186.  
  187.  
  188.  
  189. #ifdef __cplusplus
  190. } /* extern "C" */
  191. #endif
  192. #endif    /* __YGREP_H__ */
  193.